//设置页面 UI
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hive_storage/presentation/settings/settings_viewmodel.dart';
import 'package:hive_storage/presentation/widgets/settings_switch.dart';
import 'package:provider/provider.dart';

class SettingsPage extends HookWidget {
  const SettingsPage({super.key});

  @override
  Widget build(BuildContext context) {
    final viewModel = context.watch<SettingsViewmodel>();
    final settings = viewModel.settings;

    return Scaffold(
      appBar: AppBar(title: const Text('Settings')),
      body: ListView(
        children: [
          SettingsSwitch(
              title: "Dark Mode",
              value: settings.isDarkMode,
              onChanged: (value) => viewModel
                  .updateSettings(settings.copyWith(isDarkMode: value))),
          SettingsSwitch(
              title: "Enable Notifications",
              value: settings.notificationsEnabled,
              onChanged: (value) => viewModel.updateSettings(
                  settings.copyWith(notificationsEnabled: value))),
        ],
      ),
    );
  }
}
